<template>
    <div class='prize'>
        <div style="width:100%; height:2rem"></div>
        <div class="tiger">
            <div class="btns">
                <span class="prizes1">
                    <div class=prizeText>{{voucherText}}</div> 
                </span> 
                <span class="prizes2"> 
                    <div class=prizeText>{{fareText}}</div> 
                </span> 
                <span class="prizes3">
                   <div class=prizeText>{{bodyText}}</div> 
                </span> 
            </div> 
            <div class="hbText" >
               电影票（有效期截止5月30日）请至碧桂园世纪滨江营销中心领取；电冰箱、电饭煲请至碧桂园凤凰湾营销中心领取；其他礼品请至活动规则里展示项目就近领取。
            </div> 
        </div> 
    
        <div class="return" @click="ret">
            <img src="http://assets.rurushishi.com/activies/bgyAct/return.png" alt="">
            <div class="retext">返回首页</div>
        </div>
        <Bottom :baseText="baseText"></Bottom>

    </div>
</template>
<script>
import request from "@/utils/request";
import axios from "axios";
//import { mapMutations } from "vuex";
//import wxsdk from "@/utils/wxsdk";
import {MessageBox} from "mint-ui";
import { mapState, mapMutations } from "vuex";
import wx from "weixin-js-sdk";
import * as config from "./config";
import Cookies from "js-cookie";
import Share from "@/components/common/Share";
import Bottom from "@/components/common/Bottom";
import Qs from "qs";
export default {
    data(){
        return {
            isFocus:false,
          getStarNums:'', //红包文案
          isPrize :false,
          registeroid:this.$route.query.registeroid ? this.$route.query.registeroid : '', //销售中介的openid
          bodyText:'未中奖',
          voucherText: '未中奖',
          fareText: '未中奖',
           prize:'购房优惠券',
            
            openid: Cookies.get("openid"),
            baseText: config.BASE_TEXT,
        }
    },

    components: {
        Bottom
    },

    methods:{
         //返回首页
        ret(){
            // this.$router.push({path:"./index",query:{channel:this.channel,reOpenid:this.reOpenid}});
             window.location.href = location.protocol + '//' + location.host + '/act/bgyact/index?channel=' + this.channel + '&reOpenid=' + this.openid;
        },

        
      //查询大转盘中奖信息
        getprize(){
          // /api/lightenstar/selectLuckPrize
          let _self = this;
            let query = {
                activityId: 12,
                openId: Cookies.get("openid")
            };
            axios
                .get(`${_self.global.API_FORUM_URL}/api/lightenstar/selectLuckPrize?${Qs.stringify(
                    query
                )}`,{}).then(response => {
                console.info(response)
                if(response.code==0){
                
                    //领取过话费
                    if(response[3]==null){
                       //未中奖

                    }else if(response[3].prize){
                        //已领取
                        _self.fareText = response[3].prize
                    }

                    if(response[4]==null){
                       //未中奖

                    }else if(response[4].prize){
                        //已领取
                        _self.bodyText = response[4].prize
                    }
                }
            });
            
        },
        //中奖列表
       getPeizeList(){
            let _self = this;
            let query = {
                activityId: config.ACT_CODE,
                openId: Cookies.get("openid")
            };
            axios
                .get(
                `${_self.global.API_FORUM_URL}/api/activity/getMyPrizes?${Qs.stringify(
                    query
                )}`,
                {}
                )
                .then(response => {
                // console.info(response)
                if(response.code==0){
                  // 1 话费，2 优惠券，3 助力奖,  4 大转盘，5 分享红包
                    //领取过话费
                    // if(response[1]==null){
                    //    //未中奖

                    // }else if(response[1].prize){
                    //     //已领取
                    //     _self.fareText = response[1].prize
                    // }

                    if(response[2]==null){
                       //未中奖

                    }else if(response[2].prize){
                        //已领取
                        _self.voucherText = '购房优惠券'
                    }
                    // if(response[4]==null){
                    //    //未中奖

                    // }else if(response[4].prize){
                    //     //已领取
                    //     _self.bodyText = response[4].prize
                    // }
                }
            });
        },
       

       
   

    ...mapMutations({
      setInfo: "SET_INFO",
      setChannel: "SET_CHANNEL"
    })

    
  },
  computed: {
    ...mapState(["info", "channel"])
  },
  created(){
       this.setChannel(this.$route.query.channel ? this.$route.query.channel : 0);
       const _self = this
          _self.global.SHARE_CALLBACK_OK = function (type) {
            //  let _self = this;
             let query = {
                activityId: config.ACT_CODE,
                // channel: 1,
                openId: Cookies.get("openid")
              };
                axios
                    .post(
                    `${_self.global.API_FORUM_URL}/api/activity/share?${Qs.stringify(
                      query
                    )}`,
                    {
                      
                    })
                    .then(response => {
                        if(response.code==0){
                          _self.isshare = false;
                        }
                         
                    });

            };

            //  let _self =this;
            //  if(!_self.info.nickname){
                request
                    .get(_self.global.API_URL, {
                        action: "getUserinfo",
                        requestParam: {
                          
                        }
                    })
                    .then(response => {
                        _self.setInfo(response.obj.user);
                        // console.log(response.obj.salerOrAgent);
                        if(response.obj.salerOrAgent){
                          _self.registeroid=response.obj.user.openid
                          //  _self.registeroid = Cookies.get("openid")
                        }
                        // console.log(_self.info);
                        if (_self.info && _self.info.nickname && _self.info.nickname != '') {
                            _self.global.SHARE_TITLE = _self.info.nickname + "邀请你参加碧桂园27周年庆专属优惠 最大折合9折";
                        }
                        _self.global.SHARE_LINK = location.protocol + '//' + location.host + '/act/bgyact/main?channel=' + _self.channel + '&reOpenid=' + _self.openid+'&registeroid='+_self.registeroid;
                    });
            // _self.global.SHARE_TITLE = _self.info.nickname + "邀请你参加碧桂园27周年庆专属优惠 最大折合9折";
            // _self.global.SHARE_LINK = location.protocol + '//' + location.host + '/act/bgyact/main?channel=' + _self.channel + '&reOpenid=' + _self.openid;
            config.initShare();
  },
  mounted(){
      this.getPeizeList(); //查询中奖
      this.getprize(); //
      // this.getHb();  //是否领取红包
     
  }

}
</script>
<style lang = "stylus" scoped>
.prize{
    position absolute
    top 0
    left 0
    right 0
    bottom 0
    background url(http://assets.rurushishi.com/activies/bgyAct/bg7.jpg) no-repeat
    background-size 100% 100%
}
.tiger{
    position relative
    width 6.22rem
    height 8.52rem
    background url(http://assets.rurushishi.com/activies/bgyAct/prizes4.png) no-repeat
    background-size 100% 100%
    margin  0 auto
}
.btns{
    position absolute
    top 2.3rem
    width 80%
    left 10%
    margin 0 auto
    display flex
    justify-content center
}
.btns>span{
    margin 0 .1rem
    width 1.58rem
    height 3.23rem
    margin  0 auto 
}
.btns .prizes1{
    background url(http://assets.rurushishi.com/activies/bgyAct/prizes1.png) no-repeat
    background-size 100% 100%
}
.btns .prizes2{
    background url(http://assets.rurushishi.com/activies/bgyAct/prizes8.jpg) no-repeat
    background-size 100% 100%
}
.btns .prizes3{
    background url(http://assets.rurushishi.com/activies/bgyAct/prizes9.jpg) no-repeat
    background-size 100% 100%
}
.prizeText{
  width 100%
  margin  0 auto
  padding-top 1.5rem 
  height 1.6rem
  line-height .4rem
  text-align  center
}

.hbText{
    position absolute
    top 6.5rem
    width 86%
    left 7%
    margin 0 auto
    text-align center
    line-height .4rem
    font-size .28rem
    color #fff
}
.return{
    position absolute
    bottom  1.2rem
    right 0
    width: 1.2rem
    text-align center
    vertical-align middle
}
.return>img{
    width: .81rem
    // width: 100%
    height: 100%
}
.retext{
  line-height .5rem
  font-size .24rem
  color #fff
}


</style>


